package com.example.tree.utils;

import com.github.hui.quick.plugin.qrcode.wrapper.QrCodeGenWrapper;
import com.github.hui.quick.plugin.qrcode.wrapper.QrCodeOptions;
import com.google.zxing.WriterException;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import java.awt.image.BufferedImage;
import java.io.IOException;

public class GenerateQrCodeUtil {

    public static BufferedImage getQrCode(String url) throws IOException, WriterException {
        BufferedImage qrImage = QrCodeGenWrapper.of(url)
                .setDrawEnableScale(true)    // 启用抗锯齿缩放
                .setDrawStyle(QrCodeOptions.DrawStyle.RECT)  // 2025年推荐矩形样式
                .setErrorCorrection(ErrorCorrectionLevel.H)
                .asBufferedImage();
        return qrImage;
    }
}
